import { defineStore } from "pinia";
import {ref} from 'vue';

export const useTokenStore = defineStore('token',()=>{

    //1.定义描述token
    const token = ref('')
    const role = ref('')

    //2.定义修改token的方法
    const setToken = (newToken)=>{
        token.value = newToken
    }

    //3.定义移除token的方法
    const removeToken = ()=>{
        token.value=''
        role.value = '';
    }

    const setRole = (newRole) => {
        role.value = newRole;
    };

    return {
        token,setToken,removeToken,
        role, setRole
    }
}
,
//参数持久化
    {
        persist:true
    }
)